<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header('盘点出库作业管理')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="col-sm-12 search-collapse">
        <form id="user-form">
            <div class="select-list">
                <ul>

                    <input name="inOut" type="text" value="9" hidden="hidden">
                    <li>
                        <label>作业状态：</label>
                        <select name="status" required>
                            <option value="3">正执行</option>
                            <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
                        </select>
                    </li>
                    <li>
                        <label>任务号：</label><input type="text" name="taskNo"/>
                    </li>
                    <!--<li>-->
                    <!--<label>托盘条码：</label><input type="text" name="trayCode"/>-->
                    <!--</li>-->
                    <li>
                        <label>创建时间：</label>
                        <input type="text" placeholder="请单击选择开始时间：" name="beginDate" id="beginDate"/>---
                        <input type="text" placeholder="请单击选择结束时间：" name="endDate" id="endDate"/>
                    </li>
                    <!--<li>-->
                        <!--出入库类型：-->
                        <!--<select id="inOrOut" name="inOrOut" th:height="300px">-->
                            <!--<option value="14">盘点出库</option>-->
                        <!--</select>-->
                    <!--</li>-->
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
    <div class="btn-group-sm" id="toolbar" role="group">
        <!--<a class="btn btn-success" onclick="handFinish()" shiro:hasPermission="mydo:mydojob:handFinish">-->
        <!--<i class="fa fa-plus"></i> 手动完成-->
        <!--</a>-->
        <a class="btn btn-danger" onclick="update()" shiro:hasPermission="mydo:mydojob:handInvalid">
            <i class="fa fa-trash-o"></i> 修改执行阶段
        </a>
        <span>执行阶段：</span>
        <select id="execution" th:with="type=${@dict.getType('job_execution_in')}" class="btn btn-default" style="width:160px;color: #004d8c">
            <option value="">--请选择--</option>
            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
        </select>

    </div>

    <div id="div1" style="height: 350px" class="col-sm-8 select-table">
        <table id="bootstrap-table" data-mobile-responsive="true"></table>
    </div>
    <div id="div2" style="height: 350px" class="col-sm-8 select-table">
        <table id="bootstrap-table2" data-mobile-responsive="true"></table>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "mydo/mydojobout"
    var job_status = [[${@dict.getType('job_status')}]];
    var jobExeDatas = [[${@dict.getType('job_execution_in')}]];

    layui.use('laydate', function () {
        var laydates = layui.laydate;
        laydates.render({
            elem: '#beginDate'
            , type: 'datetime',
            /* ,range: '到' */
            format: 'yyyy-MM-dd HH:mm:ss'
        })
    })

    layui.use('laydate', function () {
        var laydates = layui.laydate;
        laydates.render({
            elem: '#endDate'
            , type: 'datetime',
            /* ,range: '到' */
            format: 'yyyy-MM-dd HH:mm:ss'
        })
    })

    //子表
    var options2 = {
        search: false,
        showRefresh: true,
        showColumns: true,
        minimumCountColumns: 2,
        clickToSelect: true,//是否启用点击选中行
        height: $("#div2").height() / 1,
        sortName: "jobDetailId",
        sortOrder: "asc",
        modalName: "盘点出库子作业",
        method: 'post',
        striped: true, //是否显示行间隔色
        pagination: true,//显示分页
        sidePagination: "client",
        pageNumber: 1,
        pageSize: 15,
        pageList: [10, 25],
        columns:
            [{
                checkbox: true,
            },
                {
                    field: 'jobDetailId',
                    title: '子表编号'
                },
                {
                    field: 'jobId',
                    title: '主表编号',
                    sortable: true
                },
                // {
                //     field: 'lotNo',
                //     title: '批号',
                //     visible: false
                // },

                {
                    field: 'productGuid',
                    title: '物资guid',
                    visible: false
                },
                {
                    field: 'productId',
                    title: '物品编号',
                    align: 'center',

                },
                {
                    field: 'productName',
                    title: '物品名称',
                    align: 'center',

                },
                // {
                //     field: 'spec',
                //     title: '规格',
                //     align: 'center',
                //
                // },
                {
                    field: 'specialFlag',
                    title: '存货所需的焊接次数',
                    visible: true

                },
                {
                    field: 'productFlag',
                    title: '焊接编码',
                    visible: true

                },
                {
                    field: 'model',
                    title: '规格',
                    visible: true

                },
                {
                    field: 'unit',
                    title: '单位',
                    visible: true

                },
                {
                    field: 'length',
                    title: '焊接次数',
                    align: 'center',

                },
                {
                    field: 'grade',
                    title: '是否拼接',
                    align: 'center',

                },
                {
                    field: 'outQuantity',
                    title: '数量',
                    sortable: true,
                }
            ],
        onLoadSuccess(data) {
            switch (data.code) {
                case  500:
                    options2.url = "";
                    $('#bootstrap-table2').bootstrapTable("removeAll")
                    $.modal.alertWarning("查询出错！");
                    break;
                default:
                    break;
            }
        },
    }
    $('#bootstrap-table2').bootstrapTable(options2)
    //主表
    var options = {
        url: "/mydo/mydojobout/list",
        detailView: false,//父子表
        search: false,
        showRefresh: true,
        singleSelect:true,
        showColumns: true,
        height: $("#div1").height() / 1,
        minimumCountColumns: 2,
        clickToSelect: true,//是否启用点击选中行
        createUrl: prefix + "/add",
        updateUrl: prefix + "/edit/{id}",
        removeUrl: prefix + "/remove",
        handFinishUrl: prefix + "/handFinish",
        handInvalidUrl: prefix + "/handInvalid",
        changeJobStatusUrl: prefix + "/changeJobStatus",
        sortName: "create_time",
        sortOrder: "asc",
        modalName: "盘点出库主作业",
        columns: [{
            checkbox: true
        },
            {
                field: 'jobId',
                title: '作业id'
            },
            {
                field: 'status',
                title: '作业状态',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(job_status, value);
                }
            },

            {
                field: 'taskNo',
                title: '任务号'
            },
            // {
            //     field: 'trayCode',
            //     title: '托盘码'
            // },
            {
                field: 'roadwayId',
                title: '巷道'
            },
            {
                field: 'cargoSpaceId',
                title: '货位'
            },
            {
                field: 'priority',
                title: '优先级'
            },
            {
                field: 'executionPhase',
                title: '执行阶段',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(jobExeDatas, value);

                }
            },
            {
                field: 'inOrOut',
                title: '出库类型',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return "工件入库";
                    }else if(value==2){
                        return "焊接入库"
                    }else if(value==3){
                        return "工装入库"
                    }else if(value==4){
                        return "辅件入库"
                    }else if(value==5){
                        return "盘点入库"
                    }else if(value==6){
                        return "其他件入库"
                    }else if(value==10){
                        return "半成品出库"
                    }else if(value==11){
                        return "焊接出库"
                    }else if(value==12){
                        return "拼接出库"
                    }else if(value==13){
                        return "工装出库"
                    }else if(value==14){
                        return "盘点出库"
                    }else if(value==15){
                        return "其他出库"
                    }else if(value==16){
                        return "指定货位出库"
                    }else if(value==17){
                        return "辅件出库"
                    }
                }
            },
            {
                field: 'createTime',
                title: '创建时间'
            },
            {
                field: 'startTime',
                title: '开始时间'
            },
            {
                field: 'finishTime',
                title: '完成时间'
            },
            {
                field: 'exitId',
                title: '出口'
            }
        ],
        //双击显示主表
        onClickRow: function (t, e) {
            options2.url = ctx + "mydo/detail/list?jobId=" + t.jobId + "&status=" + t.status;
            $('#bootstrap-table2').bootstrapTable("refresh", options2)
        }
    };
    $.table.init(options);




function update(){
    var row = $("#bootstrap-table").bootstrapTable('getSelections');
    if (row.length==0){
        $.modal.alertWarning("请选择一条需要修改的数据")
        return
    }
    var exe=$("#execution").val();
    if(exe==""){
        $.modal.alertWarning("请选择要修改的执行阶段")
        return
    }
    $.post("/device/executionCheck/update", {
        jobId: row[0].jobId,
        executionPhase:exe
    }, function (result) {
        $.modal.alertWarning(result.msg);
        window.location.reload();
    })

}


</script>
</body>
</html>